import request from '@/utils/request'
// import qs from 'qs'

// 获取菜单详情
export const get_menus_detail = id => {
  return request({
    url: `/resource/${id}`,
    method: 'get'
  })
}

// 更新菜单
export const update_menus_detail = data => {
  return request({
    url: `/resource`,
    method: 'put',
    data
  })
}

// 新增菜单
export const add_menus_detail = data => {
  return request({
    url: `/resource`,
    method: 'post',
    data
  })
}

export const upload_file = data => {
  return request({
    url: '/files',
    method: 'post',
    data
  })
}

// 获取菜单树列表
export const get_menus_list = params => {
  return request({
    url: '/resource/listTree',
    method: 'get',
    params
  })
}

// 删除菜单
export const del_menus = (code) => {
  return request({
    url: `/resource/${code}`,
    method: 'delete'
  })
}

// 获取页面鉴权列表
export const get_menus_api_list = params => {
  return request({
    url: '/resourceRouting/list',
    method: 'get',
    params
  })
}

// 获取菜单
export const get_menus2 = id => {
  return request({
    url: `/resource/${id}`,
    method: 'get'
  })
}

// 更新菜单权限
export const update_resource = (data) =>{
  return request({
    url: '/resource',
    method: 'put',
    data
  })
}

// 添加角色
export const add_roles = data => {
  return request({
    url: '/role',
    method: 'post',
    data
  })
}

// 用户绑定角色
export const bind_role = data => {
  return request({
    url: '/gongRole/saveGongUserRoleOrg',
    method: 'post',
    data
  })
}

// 编辑角色
export const edit_roles = data => {
  return request({
    url: '/role',
    method: 'put',
    data
  })
}

// 添加角色2
export const add_roles2 = data => {
  return request({
    url: '/gongRole',
    method: 'post',
    data
  })
}

// 编辑角色2
export const edit_roles2 = data => {
  return request({
    url: '/gongRole',
    method: 'put',
    data
  })
}
// 删除角色
export const delete_roles = data => {
  return request({
    url: `/role/${data}`,
    method: 'delete',
  })
}

// 角色列表
export const get_roles_list = params => {
  return request({
    url: '/role/list',
    method: 'get',
    params
  })
}

// 角色列表2
export const get_roles_list2 = params => {
  return request({
    url: '/gongRole',
    method: 'get',
    params
  })
}

// 角色绑定菜单
export const bind_menus_roles = data => {
  return request({
    url: '/role/bind',
    method: 'post',
    data
  })
}

// 禁用角色
export const enable_roles = data => {
  return request({
    url: '/role/modifyStatus',
    method: 'put',
    data
  })
}

// 获取当前绑定的角色
export const get_roles_bind = id => {
  return request({
    url: `/role/resourceIds/${id}`,
    method: 'get'
  })
}

// 获取角色绑定的菜单
export const get_menus_bind = params => {
  return request({
    url: '/resource/listTree',
    method: 'get',
    params
  })
}
// 接口鉴权
// 列表
export const get_api_list = params => {
  return request({
    url: '/resourceRouting/listPage',
    method: 'get',
    params
  })
}
// 根据平台类型获取模块名称
export const get_api_module = params => {
  return request({
    url: `/resourceRouting/resourceNames/${params.platform}`,
    method: 'get',
  })
}
// 鉴权新增新增
export const resource_routing_save = (data)=> {
  return request({
    url: '/resourceRouting',
    method: 'post',
    data
  })
}
// 鉴权编辑
export const resource_routing_put = (data)=> {
  return request({
    url: '/resourceRouting',
    method: 'put',
    data
  })
}
// 鉴权详情
export const resource_routing_detail = (id)=> {
  return request({
    url: `/resourceRouting/${id}`,
    method: 'get',
  })
}
// 鉴权删除
export const resource_routing_delete = (id)=> {
  return request({
    url: `/resourceRouting/${id}`,
    method: 'delete',
  })
}

// 更改菜单状态
export const change_resource_status = (data)=> {
  return request({
    url: `/resource/modifyStatus`,
    method: 'put',
    data
  })
}

// 根据上级获取下级区划
export const get_area_list_by_parentcode = areaCode => {
  return request({
    url: `/area/nextAreaList/${areaCode}`,
    method: 'get',
  })
}

// 获取当前区划信息
export const get_area_detail = areaCode => {
  return request({
    url: `/area/${areaCode}`,
    method: 'get',
  })
}
// 新增区划
export const add_area = data => {
  return request({
    url: `/area`,
    method: 'post',
    data
  })
}
// 设置区划状态
export const set_area_status = data => {
  return request({
    url: `/area/changeStatus`,
    method: 'put',
    data
  })
}
// 机构类型树
export const get_org_type_tree = pid => {
  return request({
    url: `/orgType/tree/${pid}`,
    method: 'get',
  })
}
// 新增机构类型
export const add_org_type = data => {
  return request({
    url: `/orgType`,
    method: 'post',
    data
  })
}
// 编辑机构类型
export const edit_org_type = data => {
  return request({
    url: `/orgType`,
    method: 'put',
    data
  })
}
// 获取机构类型详情
export const get_org_type_detail = id => {
  return request({
    url: `/orgType/${id}`,
    method: 'get',
  })
}

// 获取账号列表-分页
export const get_account_list = params => {
  return request({
    url: `/user/listPage`,
    method: 'get',
    params
  })
}
// 切换机构类型状态
export const change_org_type_status = data => {
  return request({
    url: `/orgType/changeStatus`,
    method: 'put',
    data
  })
}

// 编辑用户
export const edit_account = data => {
  return request({
    url: `/user`,
    method: 'put',
    data
  })
}

// 新增用户
export const add_account = data => {
  return request({
    url: `/user`,
    method: 'post',
    data
  })
}

// 删除用户
export const delete_account = id => {
  return request({
    url: `/user/${id}`,
    method: 'delete'
  })
}

// 重置密码
export const reset_password = data => {
  return request({
    url: `/user/resetPasswrod`,
    method: 'post',
    data
  })
}

// 解锁账号
export const cancel_account = data => {
  return request({
    url: `/user/unlockUser`,
    method: 'put',
    data
  })
}

// 获取当前用户绑定的机构及角色列表
export const get_org_by_account = data => {
  return request({
    url: `/user/roleOrgList/${data.id}`,
    method: 'get'
  })
}

// 绑定角色机构
export const bind_roles = data => {
  return request({
    url: `/user/saveUserRole`,
    method: 'post',
    data
  })
}

// // 修改绑定角色机构
// export const edit_bind_roles = data => {
//   return request({
//     url: `/user/updateUserRoleOrg`,
//     method: 'put',
//     data
//   })
// }


// 获取机构绑定的角色详情
export const get_roles_bind_detail = id => {
  return request({
    url: `/user/roleOrg/${id}`,
    method: 'get'
  })
}

// 获取机构绑定自定义角色详情
export const get_role_bind_detail = id => {
  return request({
    url: `/gongRole/roleOrgList/${id}`,
    method: 'get'
  })
}

// 删除角色绑定关系
export const delete_bind_roles = id => {
  return request({
    url: `/user/removeRoleOrg/${id}`,
    method: 'delete'
  })
}

// 机构管理树
export const get_org_tree = id => {
  return request({
    url: `/organization/next/${id}`,
    method: 'get'
  })
}

// 机构下拉
export const get_org_tree2 = params => {
  return request({
    url: `/organization/nextChildren`,
    method: 'get',
    params
  })
}
// 产权信息登记机构树
export const get_org_tree3 = params => {
  return request({
    url: `/organization/nextAssetsChildren`,
    method: 'get',
    params
  })
}


// 全部机构类型 列表
export const get_org_type_list = () => {
  return request({
    url: `/orgType/list`,
    method: 'get'
  })
}
// 获取机构详情
export const get_org_detail = id => {
  return request({
    url: `/organization/${id}`,
    method: 'get',
    headers:{
      showLoading:true
    }
  })
}
// 添加机构
export const add_org = data => {
  return request({
    url: `/organization`,
    method: 'post',
    data
  })
}
// 添加机构
export const edit_org = data => {
  return request({
    url: `/organization`,
    method: 'put',
    data
  })
}
// 修改机构状态
export const change_org_status = id => {
  return request({
    url: `/organization/changeStatus/${id}`,
    method: 'put',
  })
}
// 获取下拉接口
export const get_select_options = (url,params) => {
  return request({
    url,
    method: 'get',
    params
  })
}
// 获取区划下拉接口
export const get_area_list = () => {
  return request({
    url:'/area/list',
    method: 'get'
  })
}

// 获取工会下拉接口
export const get_org_list = (params) => {
  return request({
    url:'/organization/orgList',
    method: 'get',
    params
  })
}